'use strict';

const Controller = require('egg').Controller;

class UserController extends Controller {
  constructor(ctx) {
    super(ctx);
  }


  async get() {
    const { ctx, config } = this;
    const result = await ctx.service.library.get();
    ctx.body = result
  }

  async update() {
    const { ctx, config } = this;

    let user = ctx.state.user;
    if (user.role != 'admin') {
      ctx.throw(403, "用户权限不足！");
    }
    let request = ctx.request.body;
    const result = await ctx.service.library.update(request);
    ctx.body = result
  }

}

module.exports = UserController;

